package com.shj.web.controller;

import com.shj.model.PageRequest;
import com.shj.model.PageResult;
import com.shj.model.SysMember;
import com.shj.service.SysMemberService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (SysMember)表控制层
 *
 * @author makejava
 * @since 2020-03-12 12:49:36
 */
@Controller
@RequestMapping("/member")
public class SysMemberController {
    /**
     * 服务对象
     */
    @Resource
    private SysMemberService sysMemberService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("/one")
    @ResponseBody
    public SysMember selectOne(Integer id) {
        return this.sysMemberService.queryById(id);
    }

    @GetMapping("/list")
    @ResponseBody
    public PageResult findAll(PageRequest pageRequest) {
        return sysMemberService.findPage(pageRequest);
    }

    @PostMapping("/add")
    @ResponseBody
    public SysMember addMember(@RequestBody SysMember sysMember) {
        return sysMemberService.insert(sysMember);
    }

    @PostMapping("/update")
    @ResponseBody
    public SysMember updateMember(@RequestBody SysMember sysMember) {
        return sysMemberService.update(sysMember);
    }

    @GetMapping("/delete")
    @ResponseBody
    public void deleteMember(int id) {
        sysMemberService.deleteById(id);
    }

}